package top.kaoshanji.p3ch12a.genericcomponent;

/**
 * 代码清单-p3ch12a-403页a：使用泛型的并行继承层次结构的实现示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/6 20:12
 */
public class GenericComponent {

    public void render() {
        ButtonRenderer renderer = new ButtonRenderer();
        renderer.render(new Button());
    }

}

abstract class Component { }

abstract class ComponentRenderer <C extends Component> {
    abstract void render(C component);
}

class Button extends Component { }

class ButtonRenderer extends ComponentRenderer<Button> {
    @Override
    void render(Button component) {
        // 界面渲染
    }
}
